package com.zjlanyun.erp;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import com.zjlanyun.erp.interior.InteriorMainGrid;

public class LaunchActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.launch_activity);
        ((MainApplication) getApplication()).addActivity(this);

        //等待两秒再进入
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                SharedPreferences userinfo = getSharedPreferences("userinfo", 0);

                //判断用户是否已经登录
                if (userinfo.getBoolean("isLogin", false)) {
                    Intent intent;
                    switch (userinfo.getInt("usertype", 0)) {
                        case Data.USER_TYPE_INTERIOR:
//                            startActivity(new Intent(LaunchActivity.this, InteriorMainActivity.class));
                            startActivity(new Intent(LaunchActivity.this, InteriorMainGrid.class));
                            break;
                        case Data.USER_TYPE_CUSTOMER:
                            intent = new Intent(LaunchActivity.this, CMainActivity.class);
                            startActivity(intent);
                            break;
                        case Data.USER_TYPE_SUPPLIER:
                            intent = new Intent(LaunchActivity.this, SMainActivity.class);
                            startActivity(intent);
                            break;
                    }
                } else {
                    startActivity(new Intent(LaunchActivity.this, Home.class));
                }
                finish();
            }
        }, 2000);
    }

}
